<?php 
	Class Activity extends CI_Controller{
		public function __construct(){
			parent::__construct();
			$this->load->model('model_guild');	
			$this->load->model('model_restaurant');	
			$this->load->model('model_activityprice');
			$this->load->model('model_activity');	
			$this->load->model('model_package');	
			$this->load->model('model_flight');	
			$this->load->model('model_car');	
			$this->load->model('model_activityreview');	
			$this->load->model('model_activitybanner');	
		}	
		
		public function search(){			
			$price='';
			if(isset($_GET['price'])){
				if(intval($_GET['price'])==1) $price=" and (pricefor1>0 and pricefor1<=49) ";
				if(intval($_GET['price'])==2) $price=" and (pricefor1>=50 and pricefor1<=99) ";
				if(intval($_GET['price'])==3) $price=" and (pricefor1>=100 and pricefor1<=149) ";
				if(intval($_GET['price'])==4) $price=" and pricefor1>149 ";
			}
			$type='';
			if($_GET['type']!=0) $type=" and typeofactivity like '%".$_GET['type']."%'";	
			$sortby='price';
			$name='';
			$datefrom=$_GET['datefrom'];
			$data['data']=$this->model_activity->get_search($_GET['provide'],$type,$price,$sortby,$name,$datefrom,10,0);
			$data['listbanner']=array();
			foreach($data['data'] as $k=>&$list){
				if($list['price']==NULL){
					unset($data['data'][$k]);
				}
				$data['listbanner'][]=$this->model_activitybanner->gettopbanner_search($list['id']);
			}
			$data['total']=$this->model_activity->get_search($_GET['provide'],$type,$price,$sortby,$name,$datefrom,1000000000,0);
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data['template']='activity/activity_search_result';
			$this->load->view('layout',$data);
		}
		public function detail($idactivity){
			$data['idactivity']=intval($idactivity);
			$today=getdate();
			if(isset($_GET['datefrom'])) $datefrom=date("Y-m-d",strtotime($_GET['datefrom']));
			else $datefrom= $today['year']."-".$today['mon']."-".$today['mday'];
			if(isset($idactivity)){
				$data['data']=$this->model_activity->getdata(intval($idactivity));
				$data['price']=$this->model_activityprice->getpricebyid_date($data['data']['id'],$datefrom);
				$data['banner']=$this->model_activitybanner->getallbyactivityid($data['data']['id']);
			}			
			$data["restaurant"]=$this->model_restaurant->gettopByprovide_status($data['data']['provide'],0,6,0);
			$data["activities"]=$this->model_activity->gettopByprovide_status($data['data']['provide'],0,6,0);
			$data["package"]=$this->model_package->gettopByprovide_status($data['data']['provide'],0,6,0);
			$data["flight"]=$this->model_flight->gettopByprovide_status($data['data']['provide'],0,6,0);
			$data["car"]=$this->model_car->gettopByprovide_status($data['data']['provide'],0,3,0);
			$data["guide"]=$this->model_guild->gettopByprovide_status($data['data']['provide'],0,3,0);
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data['template']='activity/detail';
			$this->load->view('layout',$data);	
		}
		public function activityinmyanmar(){
			$data['daytour']=$this->model_activity->countbytype('Day Tour & Sightseeing');
			$data['cultural']=$this->model_activity->countbytype('Cultural touch');
			$data['active']=$this->model_activity->countbytype('Active');
			$data['spa']=$this->model_activity->countbytype('Spa & Massage');
			$data['shopping']=$this->model_activity->countbytype('Shopping');

			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data['template']='activity/myanmar';
			$this->load->view('layout',$data);	
		}
	}
?>